/* 基础样式 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Arial", sans-serif;
  line-height: 1.6;
  background-color: #f5f5f5;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: #8fdedb;
  color: white;
}

/* .app-header h1 {
  color: #616acc;
  font-size: 2.5rem;
} */
.app-header h1 {
  font-family: Arial, sans-serif; /* 原有字体 */
  color: #616acc;
  font-size: 2.5rem;

  text-shadow: 3px 3px 0 #f0f0f0; /* 3D 效果 */
  letter-spacing: 1px; /* 字母间距 */
}

.app-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 编辑器容器 */
.editor-container {
  display: flex;
  flex-direction: row;
  gap: 20px;
  margin-bottom: 20px;
  /* Add height to container to enable scrolling */
  height: calc(100vh - 150px); /* Adjust based on your header/footer height */
  overflow: hidden; /* Prevent container from scrolling */
}

/* 画布容器样式 - 根据是否有图片显示不同样式 */
.meme-canvas-container {
  flex: 1;
  min-width: 300px;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  height: calc(100vh - 200px);
  overflow: hidden; /* 禁止滚动 */
  padding: 10px;
  border: none;
  border-radius: 0;
  background-color: transparent;
}

/* 画布包装器 - 基础样式 */
.canvas-wrapper {
  width: 100%;
  height: calc(100% - 80px); /* 减去按钮区域高度 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* 居中显示 */
  overflow: hidden; /* 禁止滚动 */
  position: relative;
  background-color: transparent;
  border-radius: 0;
}

/* 空画布包装器 - 显示边框 */
.canvas-wrapper.empty-canvas {
  background-color: rgba(250, 250, 250, 0.7);
  border: 2px dashed #bbb;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.canvas-wrapper.empty-canvas:hover {
  background-color: rgba(250, 250, 250, 0.9);
  border-color: #999;
}

/* 确保画布内容适应容器 */
.meme-canvas {
  max-width: 100%;
  max-height: 100% !important; /* 强制最大高度 */
  height: auto;
  width: auto;
  object-fit: contain; /* 保持宽高比缩放 */
  border: none;
  border-radius: 0;
  cursor: default;
  box-shadow: none;
  transition: all 0.3s ease;
}

/* 拖拽相关样式 */
.meme-canvas.dragging-text {
  cursor: move !important;
  box-shadow: none;
  border-color: transparent;
}

/* 空白画布提示 */
.empty-canvas-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #555;
  font-style: normal;
  background-color: transparent;
  padding: 15px 25px;
  border-radius: 8px;
  width: 80%;
  max-width: 300px;
}

.empty-canvas-hint p {
  font-size: 16px;
  margin-bottom: 0;
  line-height: 1.5;
  font-weight: 500;
}

/* 自定义上传图标 */
.empty-canvas-hint::before {
  content: "📷";
  display: block;
  font-size: 32px;
  margin-bottom: 15px;
}

/* 拖拽提示 */
.drag-tip {
  margin-top: 5px;
  font-size: 12px;
  color: #555;
  text-align: center;
  background-color: rgba(245, 245, 245, 0.8);
  padding: 5px 10px;
  border-radius: 4px;
}

/* 按钮样式优化 - 确保内容完整显示 */
.canvas-actions {
  margin-top: 10px;
  min-height: 38px;
  display: flex;
  flex-wrap: wrap; /* 允许按钮在空间不足时换行 */
  gap: 8px; /* 调整行间距 */
  justify-content: center;
  z-index: 50;
  position: sticky;
  bottom: 10px;
  left: 0;
  right: 0;
  width: 100%;
  background-color: transparent;
  padding: 10px;
  border-radius: 5px;
  box-shadow: none;
}

.canvas-actions button {
  padding: 8px 15px;
  background-color: rgba(76, 175, 80, 0.9);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  width: auto; /* 让宽度由内容决定 */
  white-space: nowrap;
  overflow: visible; /* 确保内容不会被裁剪 */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  margin: 0 3px; /* 按钮之间的间距 */
  text-align: center;
  font-size: 14px;
  backdrop-filter: blur(2px); /* 添加毛玻璃效果 */
}

/* 按钮悬停效果 */
.canvas-actions button:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
  filter: brightness(1.1);
}

.canvas-actions button:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  filter: brightness(0.95);
}

/* 控制面板 */
.controls-panel {
  flex: 1;
  min-width: 300px;
  max-width: 400px;
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  height: 100%; /* Fill the container height */
  overflow-y: auto; /* Enable scrolling */
}

.control-section {
  margin-bottom: 20px;
}

.control-section h3 {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 10px;
  color: #333;
}

.control-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  align-items: center;
}

.file-input {
  display: none;
}

.file-label {
  padding: 8px 15px;
  background-color: #2196f3;
  color: white;
  border-radius: 4px;
  cursor: pointer;
}

.file-label:hover {
  background-color: #0b7dda;
}

.template-btn {
  padding: 8px 15px;
  background-color: #ff9800;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.template-btn:hover {
  background-color: #e68a00;
}

.text-input {
  flex: 1;
  min-width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.font-select {
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.color-input {
  width: 40px;
  height: 40px;
  border: none;
  cursor: pointer;
}

.size-slider {
  flex: 1;
}

.filter-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 15px;
  background-color: #f1f1f1;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
}

.filter-btn.active {
  background-color: #4caf50;
  color: white;
}

.sticker-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.sticker-btn {
  font-size: 20px;
  padding: 5px 10px;
  background: none;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
}

.sticker-btn:hover {
  background-color: #f1f1f1;
}

/* 热门语录 */
.phrase-list {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.phrase-list h3 {
  margin-bottom: 10px;
  color: #333;
}

.phrases {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.phrase-btn {
  padding: 5px 10px;
  background-color: #e0e0e0;
  border: none;
  border-radius: 15px;
  cursor: pointer;
  font-size: 14px;
}

.phrase-btn:hover {
  background-color: #d0d0d0;
}

/* 模板模态框 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 8px;
  max-width: 800px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.close-modal {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px;
}

.template-item {
  cursor: pointer;
  text-align: center;
}

.template-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 4px;
  border: 2px solid transparent;
}

.template-item:hover .template-img {
  border-color: #4caf50;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .editor-container {
    flex-direction: column;
    align-items: center;
    overflow-y: auto; /* 允许整个容器滚动 */
  }

  .meme-canvas-container,
  .controls-panel {
    max-width: 100%;
    width: 100%;
  }

  .canvas-actions {
    gap: 6px;
    padding: 8px 5px;
  }

  .canvas-actions button {
    padding: 6px 10px;
    font-size: 13px;
    margin: 0 2px;
  }

  .template-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

.backend-status {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border-radius: 5px;
  font-weight: bold;
}

.backend-status.connected {
  background-color: #48bb78;
  color: white;
}

.backend-status.disconnected {
  background-color: #f56565;
  color: white;
}

.animation-selector {
  margin: 10px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.animation-select {
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background-color: white;
  width: 180px;
  font-size: 14px;
}

.animation-select:focus {
  outline: none;
  border-color: #4299e1;
  box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.2);
}

/* GIF预览相关样式 */
.gif-preview-container {
  position: relative;
  margin-bottom: 10px;
}

.gif-preview {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  margin: auto;
  object-fit: contain;
}

/* GIF预览控制区域 */
.preview-controls {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  gap: 10px;
  z-index: 10;
}

.close-preview {
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 15px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
}

.close-preview:hover {
  background-color: rgba(0, 0, 0, 0.9);
}

.download-gif {
  background-color: rgba(33, 150, 243, 0.8);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 15px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
}

.download-gif:hover {
  background-color: rgba(33, 150, 243, 0.95);
}

/* 文字样式控制面板样式 */
.text-style-controls {
  background-color: #f8f9fa;
  border-radius: 8px;
  padding: 15px;
  margin: 15px 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  position: relative; /* 为折叠按钮定位准备 */
  transition: max-height 0.3s ease-in-out, padding 0.3s ease-in-out,
    opacity 0.3s ease-in-out, margin 0.3s ease-in-out;
}

.text-style-controls.collapsed {
  max-height: 60px;
  overflow: hidden;
  padding-bottom: 5px;
  margin-bottom: 5px;
}

.text-style-controls h3 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 16px;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  padding-right: 25px;
}

.text-style-controls h3:after {
  content: "▼";
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  transition: transform 0.3s ease;
}

.text-style-controls.collapsed h3:after {
  transform: translateY(-50%) rotate(-90deg);
}

/* 文字输入控件样式 */
.text-input-row {
  margin-bottom: 10px;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 10px;
}

.text-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  transition: border-color 0.3s ease;
  font-size: 14px;
}

.text-input:focus {
  border-color: #4285f4;
  outline: none;
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

.text-style-separator {
  font-size: 14px;
  color: #666;
  margin: 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
  font-weight: 600;
}

.control-row {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.control-row label {
  min-width: 80px;
  margin-right: 10px;
  font-size: 14px;
}

.style-select {
  padding: 6px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background-color: white;
  width: 160px;
  font-size: 14px;
}

.range-slider {
  flex: 1;
  margin-right: 10px;
}

.color-picker {
  width: 40px;
  height: 40px;
  padding: 2px;
  border: none;
  background: none;
  cursor: pointer;
}

.checkbox-controls {
  display: flex;
  gap: 20px;
}

.checkbox-controls label {
  display: flex;
  align-items: center;
  font-size: 14px;
  cursor: pointer;
  min-width: auto;
}

.checkbox-controls input {
  margin-right: 5px;
}

.shadow-controls {
  border-left: 3px solid #ddd;
  padding-left: 15px;
  margin-left: 10px;
  margin-top: 10px;
}

.align-buttons {
  display: flex;
  gap: 5px;
}

.align-button {
  background-color: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.align-button:hover {
  background-color: #e0e0e0;
}

.align-button.active {
  background-color: #4299e1;
  color: white;
  border-color: #4299e1;
}

/* 确保控制面板在移动设备上也能良好显示 */
@media (max-width: 768px) {
  .control-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .control-row label {
    margin-bottom: 5px;
  }

  .range-slider {
    width: 100%;
  }

  .checkbox-controls {
    flex-direction: column;
    gap: 10px;
  }
}

/* 添加多文本编辑相关样式 */
.text-no-selection {
  margin: 10px 0;
  padding: 10px;
  border-radius: 5px;
  background-color: #f0f0f0;
  text-align: center;
  color: #666;
  font-style: italic;
}

/* 选中文本指示样式 */
.text-selected-indicator {
  position: absolute;
  border: 2px dashed #4285f4;
  pointer-events: none;
  transition: all 0.2s ease;
}

/* 添加文字按钮样式 */
.add-text-button-container {
  margin: 10px 0 15px 0;
  display: flex;
  justify-content: flex-start;
}

.add-text-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background-color: #4285f4;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 15px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.add-text-btn:hover {
  background-color: #3367d6;
}

.add-text-btn svg {
  font-size: 16px;
}

/* 文字列表样式 */
.text-list-container {
  margin-bottom: 15px;
}

.text-list-container h4 {
  font-size: 14px;
  margin-bottom: 8px;
  color: #333;
}

.text-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 5px;
}

.text-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background-color 0.2s;
}

.text-item:last-child {
  border-bottom: none;
}

.text-item:hover {
  background-color: #f5f5f5;
}

.text-item.active {
  background-color: #e3f2fd;
  border-left: 3px solid #4285f4;
}

.text-item-content {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 80%;
}

.text-item-content svg {
  color: #666;
  font-size: 14px;
}

.text-item-preview {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-delete-btn {
  background: none;
  border: none;
  color: #f44336;
  cursor: pointer;
  padding: 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.text-delete-btn:hover {
  opacity: 1;
}

.text-delete-btn svg {
  font-size: 16px;
}

/* 确保文字设置控制面板与新样式兼容 */
.text-style-controls {
  margin-top: 15px;
}

/* 文字未选中提示样式优化 */
.text-no-selection {
  padding: 12px;
  border-radius: 5px;
  background-color: #f5f5f5;
  color: #666;
  text-align: center;
  font-size: 14px;
  line-height: 1.4;
}

/* 删除空白画布覆盖层样式 */
.empty-canvas-overlay {
  display: none;
}

/* 按钮占位符，保持布局一致 */
.button-spacer {
  display: none;
}

/* 特定类型按钮样式 */
.canvas-actions button:nth-child(1) {
  background-color: rgba(33, 150, 243, 0.9); /* 蓝色 - 生成GIF */
  box-shadow: 0 2px 5px rgba(33, 150, 243, 0.25);
}

.canvas-actions button:nth-child(2) {
  background-color: rgba(76, 175, 80, 0.9); /* 绿色 - 保存至服务器 */
  box-shadow: 0 2px 5px rgba(76, 175, 80, 0.25);
}

.canvas-actions button:nth-child(3) {
  background-color: rgba(255, 152, 0, 0.9); /* 橙色 - 下载图片 */
  box-shadow: 0 2px 5px rgba(255, 152, 0, 0.25);
}

/* 下载GIF按钮样式 */
.download-gif-button {
  background-color: rgba(233, 30, 99, 0.9) !important; /* 粉红色 - 下载GIF */
  box-shadow: 0 2px 5px rgba(233, 30, 99, 0.25) !important;
  position: relative;
  overflow: hidden;
}

.download-gif-button:hover {
  background-color: rgba(233, 30, 99, 1) !important;
  box-shadow: 0 3px 8px rgba(233, 30, 99, 0.35) !important;
  transform: translateY(-1px);
}

.download-gif-button:after {
  content: "";
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10, 10);
  opacity: 0;
  transition: transform 0.3s, opacity 0.5s;
}

.download-gif-button:active:after {
  transform: scale(0, 0);
  opacity: 0.2;
  transition: 0s;
}

.canvas-actions button:nth-child(5),
.canvas-actions button:nth-child(4):not(.download-gif-button) {
  background-color: rgba(156, 39, 176, 0.9); /* 紫色 - 分享 */
  box-shadow: 0 2px 5px rgba(156, 39, 176, 0.25);
}

.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 10px 20px;
  border-radius: 4px;
  z-index: 30;
}

/* 禁用状态的按钮 */
.canvas-actions button:disabled {
  background-color: rgba(204, 204, 204, 0.7);
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
  transform: none;
  color: rgba(255, 255, 255, 0.8);
}

.canvas-actions button:disabled:hover {
  background-color: rgba(204, 204, 204, 0.7);
  box-shadow: none;
  transform: none;
  filter: none;
}

/* 隐藏滚动条但保持滚动功能 */
.meme-canvas-container::-webkit-scrollbar,
.controls-panel::-webkit-scrollbar {
  width: 0; /* 隐藏滚动条 */
  background: transparent; /* 可选: 使滚动条透明 */
  display: none; /* 完全隐藏滚动条 */
}

/* Firefox 浏览器支持 */
.meme-canvas-container,
.controls-panel {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE 和 Edge */
}

/* 统一设置所有滚动区域的平滑滚动 */
.meme-canvas-container,
.controls-panel,
.editor-container {
  scroll-behavior: smooth;
}

/* 画布拖拽相关样式 */
.meme-canvas.dragging {
  cursor: move !important;
  user-select: none;
}

.drag-tip {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  opacity: 0.8;
  transition: opacity 0.3s;
}

.drag-tip:hover {
  opacity: 1;
}

/* 确保画布容器有正确的定位 */
.canvas-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #f5f5f5;
  border-radius: 8px;
  overflow: hidden;
}
